﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel; 
using CourseArraging.Common;
using System.Windows.Forms;
using System.Drawing;

namespace CourseArraging.Frm.jcxx
{
    /// <summary>
    /// 版权所有
    /// 石世特@温州医学院 sst330381@gmail.com
    /// </summary> 
    public class FrmJcxxCourse : FrmJcxxBase
    {
        // Fields
        private BasicService.BasicServiceClient basicDao = new BasicService.BasicServiceClient();
        private IContainer components = null;
        protected static FrmJcxxCourse instance;

        // Methods
        public FrmJcxxCourse()
        {
            this.InitializeComponent();
            this.showData();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void frm_reflist()
        {
            this.showData();
        }

        public static FrmJcxxCourse GetInstance()
        {
            if ((instance == null) || instance.IsDisposed)
            {
                instance = new FrmJcxxCourse();
                instance.MdiParent = GlobalVar.frmMain;
            }
            instance.BringToFront();
            return instance;
        }

        private void InitializeComponent()
        {
            base.SuspendLayout();
            base.AutoScaleDimensions = new SizeF(6f, 12f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x148, 0x184);
            base.Name = "FrmJcxxCourse";
            this.Text = "课程信息";
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        public override void newForm(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView view = (DataGridView)sender;
            FrmInfoCourse course = new FrmInfoCourse(int.Parse(view.Rows[e.RowIndex].Cells[0].Value.ToString()), view.Rows[e.RowIndex].Cells[1].Value.ToString());
            course.reflist += new FrmInfoCourse.refreshlist(this.frm_reflist);
            course.ShowDialog();
        }

        public override void showData()
        {
            base.dataGridView1.DataSource = base.otherDao.getCourseInfo4table(0,null);
        }

        public override void tsb_new_fun()
        {
            FrmInfoCourse frm = new FrmInfoCourse();
            frm.reflist += new FrmInfoCourse.refreshlist(this.frm_reflist);
            frm.ShowDialog();
        }

        //public override void tsb_save_fun()
        //{
        //    if (this.basicDao.getEqualCourse(base.tstxt_item.Text.Trim()))
        //    {
        //        MessageBox.Show("已经存在该项, 请重新填写 ! ");
        //    }
        //    else
        //    {
        //        this.basicDao.addCourseInfo(base.tstxt_item.Text.Trim());
        //        MessageBox.Show("添加成功 ! ");
        //        this.showData();
        //    }
        //}
    }

 

}
